package com.zdb.Runabble;

import java.lang.ref.WeakReference;

public class main {
    public static void main(String[] args) {
        String s = new String("111");
        WeakReference<String> stringWeakReference = new WeakReference<>(s);
        s=null;
        System.gc();

        try { Thread.sleep(100); } catch (InterruptedException ignored) {}
        String s1 = stringWeakReference.get();
        if (s1 != null) {
            System.out.println("GC 后软引用仍然可用: " + s1);
        } else {
            System.out.println("GC 后软引用已被回收");
        }
    }
}
